package com.hgm.study.viewmodel

import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel

/**
 * @author    HGM
 * @version   1.0
 */
class TaskViewModel : ViewModel() {
      //任务日期
      var taskDate by mutableStateOf("学习周期:2022.01.01-2022.04.12")
            private set

      //学年总积分
      var totalPointOfYear = 13500

      //学年积分
      var pointOfYear by mutableStateOf(10000)
            private set

      //学年积分进度值 =（220f * pointOfYear / 学年总积分）
      var pointOfYearPercent by mutableStateOf(0f)
            private set

      //计算方法
      fun updatePointPercent() {
            pointOfYearPercent = 220f * pointOfYear / totalPointOfYear
      }

      //一周积分情况
      var pointsOfWeek by mutableStateOf(listOf(0.0, 1.2, 4.0, 5.3, 6.9, 12.0, 3.5))
            private set

      //日期
      var days by mutableStateOf(listOf("02.05", "02.24", "03.01", "03.22", "04.15", "08.05", "今日"))
            private set

      //今日积分
      private var todayPoint = 13

      //今日提醒文字
      var dayTips by mutableStateOf("今日获得 0 积分，快去完成下面任务吧")
            private set

      fun updateDayTips() {
            dayTips = when (todayPoint) {
                  0 -> {
                        "今日获得 0 积分，快去完成下面任务吧"
                  }
                  in 1..14 -> {
                        "今日获得 $todayPoint 积分，快去完成下面任务吧"
                  }
                  else -> {
                        "今日获得 $todayPoint 积分，已经完成任务"
                  }
            }
      }
}


